﻿using System;
using UnityEngine;

// Token: 0x020000A8 RID: 168
public class RigidEmitter_OneShot : MonoBehaviour
{
	// Token: 0x17000066 RID: 102
	// (get) Token: 0x0600053E RID: 1342 RVA: 0x0001EDCC File Offset: 0x0001CFCC
	// (set) Token: 0x0600053F RID: 1343 RVA: 0x0001EDD4 File Offset: 0x0001CFD4
	public bool Emitting
	{
		get
		{
			return this.emitting;
		}
		set
		{
			this.emitting = value;
		}
	}

	// Token: 0x06000540 RID: 1344 RVA: 0x0001EDE0 File Offset: 0x0001CFE0
	private void Start()
	{
	}

	// Token: 0x06000541 RID: 1345 RVA: 0x0001EDE4 File Offset: 0x0001CFE4
	private void Update()
	{
		this.Emitting = Input.GetKey(this.key);
		if (this.Emitting)
		{
			this.intervalTimer -= Time.deltaTime;
			if (this.intervalTimer <= 0f)
			{
				this.Emit();
			}
		}
	}

	// Token: 0x06000542 RID: 1346 RVA: 0x0001EE38 File Offset: 0x0001D038
	public void EmitStart()
	{
	}

	// Token: 0x06000543 RID: 1347 RVA: 0x0001EE3C File Offset: 0x0001D03C
	public void Emit()
	{
		for (int i = 0; i < this.emitNum; i++)
		{
			float y = UnityEngine.Random.Range(this.directionMin, this.directionMax);
			float x = UnityEngine.Random.Range(this.elevationMin, this.elevationMax);
			float d = UnityEngine.Random.Range(this.speedMin, this.speedMax);
			Quaternion rotation = base.transform.rotation * Quaternion.Euler(x, y, 0f);
			Vector3 velocity = rotation * Vector3.forward * d;
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.original);
			gameObject.SetActive(true);
			gameObject.transform.position = base.transform.position;
			gameObject.transform.rotation = base.transform.rotation;
			gameObject.transform.SetParent(this.setParent);
			Rigidbody[] componentsInChildren = gameObject.GetComponentsInChildren<Rigidbody>();
			foreach (Rigidbody rigidbody in componentsInChildren)
			{
				rigidbody.velocity = velocity;
			}
		}
		this.intervalTimer = this.interval;
	}

	// Token: 0x04000441 RID: 1089
	public GameObject original;

	// Token: 0x04000442 RID: 1090
	[Range(-180f, 0f)]
	public float directionMin;

	// Token: 0x04000443 RID: 1091
	[Range(0f, 180f)]
	public float directionMax;

	// Token: 0x04000444 RID: 1092
	[Range(-180f, 0f)]
	public float elevationMin;

	// Token: 0x04000445 RID: 1093
	[Range(0f, 180f)]
	public float elevationMax;

	// Token: 0x04000446 RID: 1094
	public float speedMin = 1f;

	// Token: 0x04000447 RID: 1095
	public float speedMax = 1f;

	// Token: 0x04000448 RID: 1096
	public int emitNum = 1;

	// Token: 0x04000449 RID: 1097
	public Transform setParent;

	// Token: 0x0400044A RID: 1098
	private float timer;

	// Token: 0x0400044B RID: 1099
	public float interval = 0.05f;

	// Token: 0x0400044C RID: 1100
	private float intervalTimer;

	// Token: 0x0400044D RID: 1101
	public KeyCode key;

	// Token: 0x0400044E RID: 1102
	private bool emitting;
}
